package com.syqc.utils

import android.content.Context
import com.syqc.comlib.utils.AppContext
import com.syqc.entity.ArrearsNotice
import com.syqc.entity.ChooseRegion
import com.syqc.entity.CmdLog
import com.syqc.entity.Expire
import com.syqc.entity.FwdRev
import com.syqc.entity.HistoryAlarm
import com.syqc.entity.HistoryLine
import com.syqc.entity.IdentityInfo
import com.syqc.entity.KeyValue
import com.syqc.entity.ListInfo
import com.syqc.entity.OilDay
import com.syqc.entity.OilPoint
import com.syqc.entity.PhotoInfo
import com.syqc.entity.PsiRpt
import com.syqc.entity.RunCar
import com.syqc.entity.RunCarState
import com.syqc.entity.SensorInfo
import com.syqc.entity.StatsType
import com.syqc.entity.StopStats
import com.syqc.entity.TmnManager
import com.syqc.entity.TypeInfo
import com.syqc.monitor.R

/** @Author Jasper @Time 2020/9/19 @Desc 视频相关帮助类 */
object DataUtil {
    private val videoResList = ArrayList<KeyValue>()


    fun getVideoRes(context: Context): MutableList<KeyValue> {
        if (videoResList.isEmpty()) {
            videoResList.add(KeyValue("0", context.getString(R.string.desc_video_res_one)))
            videoResList.add(KeyValue("1", context.getString(R.string.desc_video_res_two)))
            videoResList.add(KeyValue("2", context.getString(R.string.desc_video_res_three)))
            videoResList.add(KeyValue("3", context.getString(R.string.desc_video_res_four)))
        }
        return videoResList
    }

    private val videoStreamList = ArrayList<KeyValue>()
    fun getVideoStream(context: Context): MutableList<KeyValue> {
        if (videoStreamList.isEmpty()) {
            videoStreamList.add(
                KeyValue(
                    "0",
                    context.getString(R.string.desc_video_stream_all)
                )
            )
            videoStreamList.add(
                KeyValue(
                    "1",
                    context.getString(R.string.desc_video_main_stream)
                )
            )
            videoStreamList.add(
                KeyValue(
                    "2",
                    context.getString(R.string.desc_video_sub_stream)
                )
            )
        }
        return videoStreamList
    }

    private val videoStorageList = ArrayList<KeyValue>()
    fun getVideoStorage(context: Context): MutableList<KeyValue> {
        if (videoStorageList.isEmpty()) {
            videoStorageList.add(
                KeyValue(
                    "0",
                    context.getString(R.string.desc_video_storage_all)
                )
            )
            videoStorageList.add(
                KeyValue(
                    "1",
                    context.getString(R.string.desc_video_storage_one)
                )
            )
            videoStorageList.add(
                KeyValue(
                    "2",
                    context.getString(R.string.desc_video_storage_two)
                )
            )
        }
        return videoStorageList
    }

    /**
     * 获取存储类型描述
     *
     * @param key
     * @return
     */
    fun getStorage(key: String): String {
        return when (key) {
            "0" -> return AppContext.getDescById(R.string.desc_video_storage_all)
            "1" -> return AppContext.getDescById(R.string.desc_video_storage_one)
            else -> AppContext.getDescById(R.string.desc_video_storage_two)
        }
    }

    /**
     * 切换语言清除
     */

    fun clearVideoList() {
        videoResList.clear()
        videoStreamList.clear()
        videoStorageList.clear()
    }


    val refreshTimes by lazy {
        mutableListOf(
            KeyValue("0", "5"),
            KeyValue("1", "10"),
            KeyValue("2", "15"),
            KeyValue("3", "20"),
            KeyValue("4", "25"),
            KeyValue("5", "30")
        )
    }


    //模拟量
    var analogEntity: ArrayList<SensorInfo>? = null

    private val cmdMap = HashMap<String, String>()

    fun setCmdToMap(cmdId: String, cmdName: String) {
        cmdMap[cmdId] = cmdName
    }

    fun getCmdName(cmdId: String?): String? = cmdMap[cmdId]

    private val logMap = HashMap<String, String>()

    fun setLogToMap(cmdId: String, cmdName: String) {
        logMap[cmdId] = cmdName
    }

    fun getLogName(cmdId: String?): String? = logMap[cmdId]
    private val regionMap = HashMap<String, String>()

    fun setRegionToMap(regionId: String, regionName: String) {
        regionMap[regionId] = regionName
    }

    fun getRegionName(regionId: String?): String? = regionMap[regionId]

    //历史轨迹
    var HistoryLine: HistoryLine? = null

    //照片详情列表
    var mPhotoInfo: ArrayList<PhotoInfo>? = null

    var logCmdEntity: ArrayList<CmdLog>? = null

    var alarmInfo: ArrayList<HistoryAlarm.TotalAlarms.InfoAlarms>? = null

    var alarmEntity: HistoryAlarm? = null

    var stopCar: StopStats? = null

    //行车统计
    var runCar: RunCar? = null

    //行驶状态
    var runStates: MutableList<RunCarState>? = null

    //胎压报表
    var psiRpt: ArrayList<PsiRpt>? = null

    //轮胎数据
    var psiTyres: List<List<String>>? = null

    //选中区域
    var regionChoose: MutableList<ChooseRegion>? = null

    //选中的父id
    var chooseAllDPid: MutableList<String> = mutableListOf()
    var chooseAllAPid: MutableList<String> = mutableListOf()

    //正反转
    var fwdrevs: FwdRev? = null

    //传感器查询数据
    var dayStats: ArrayList<StatsType>? = null

    //传感器日数据
    var stats: OilDay? = null


    //模拟量详情
    var oilPints: ArrayList<OilPoint>? = null

    //加漏油
    var addLeak: ArrayList<ListInfo>? = null

    //车辆欠费详情
    var arrearsInfo: Expire? = null
    var arrears: ArrearsNotice? = null

    //类型Id
    var typeIds: ArrayList<String>? = null
    var names: ArrayList<String>? = null

    //传感器数据
    var tempNodeMap: HashMap<String, ArrayList<String>>? = null

    //传感器配置
    var typeInfos: MutableList<TypeInfo>? = null

    //未绑定车辆的终端
    var unBindTmns: MutableList<TmnManager>? = null
    //身份识别列表信息
    var identifys: MutableList<IdentityInfo>? = null
}